package org.mespilus.mespilusweb.ui.usermanagement.client;

import com.gwtext.client.data.ArrayReader;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.MemoryProxy;
import com.gwtext.client.data.RecordDef;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.grid.ColumnConfig;
import com.gwtext.client.widgets.grid.ColumnModel;
import com.gwtext.client.widgets.grid.GridPanel;

public class GroupsPanel {
	
	
	public GroupsPanel() {
	}

	public Panel getUserGroupsPanel(){
		GridPanel groupsPanel = new GridPanel();
		ColumnConfig[] groupsColumns = new ColumnConfig[]{
			new ColumnConfig("Name", "name", 175, true),
			new ColumnConfig("Description", "descr", 175, false)
		};
		ColumnModel columnModel = new ColumnModel(groupsColumns);
		groupsPanel.setColumnModel(columnModel);
		groupsPanel.setFrame(true);
		groupsPanel.setStripeRows(true);
		groupsPanel.setTitle("Groups");
		groupsPanel.setWidth(350);
		groupsPanel.setHeight(450);
		
		RecordDef recordDef = new RecordDef(
				new FieldDef[]{
					new StringFieldDef("name"),
					new StringFieldDef("descr")
				}
			);
		
		MemoryProxy userDataProxy = new MemoryProxy(new Object[][]{});
		ArrayReader userDataArrayReader = new ArrayReader(recordDef);
		Store store = new Store(userDataProxy, userDataArrayReader);
		groupsPanel.setStore(store);
		return groupsPanel;
	}
}
